<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var b = document.getElementById('box');
        console.log(b);
    </script>
</head>
<body>

<input type="button" id="btn" value="点我">
<script>
    function foo(){
        alert('我被点到了')
    }
    var btn = document.getElementById('btn');
    btn.onclick = foo;
</script>

</body>
</html>